package com.example.kuaizu.service.imp;

import com.example.kuaizu.mapper.SchoolMapper;
import com.example.kuaizu.pojo.dto.MajorCountObject;
import com.example.kuaizu.pojo.dto.SchoolCountObject;
import com.example.kuaizu.pojo.ov.SchoolMajorCount;
import com.example.kuaizu.pojo.ov.UserProofOv;
import com.example.kuaizu.service.InSchoolService;
import kuaizu.common.tablepojo.School;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Log4j2
public class SchoolService implements InSchoolService {
    @Autowired
    private SchoolMapper schoolMapper;

    //查询学校的注册人数
    @Override
    @Transactional
    public List<SchoolCountObject> getSchoolRegisterCount() {
        return schoolMapper.getSchoolRegisterCount();
    }

    //根据学校id查询学校信息
    @Override
    @Transactional
    public School selectSchoolByIdFromSchoolName(Integer id) {
        return schoolMapper.selectSchoolNameBySchoolId(id);
    }

    /*
     * 根据学校id查询对应的学生信息
     * */
    @Override
    @Transactional
    public List<UserProofOv> getStudentBySchoolId(Integer schoolId) {
        return schoolMapper.selectBySchoolIdFromUserInfo(schoolId);
    }

    @Override
    public List<SchoolMajorCount> getMajorBySchoolId(Integer schoolId) {
        return schoolMapper.getMajorBySchoolId(schoolId);
    }

    @Override
    public List<MajorCountObject> getMajorRegisterCount() {
        return schoolMapper.getMajorRegisterCount();
    }
}
